Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: parse peer id from message correctly #127

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

achingbrain
Copy link
Member

Peer IDs are sent as a buffer containing the utf bytes for /ipns/
then the bytes that make up the peer id.

Our tests were using a buffer that contained the utf bytes for /ipns/
followed by the utf bytes for the base encoded peer id, which is wrong.

I think this only worked previously because the validator passed the
bytes to PeerId.createFromBytes which passes them to the cids CID
class constructor which is a lot more forgiving in terms of input than
the multiformats CID class.

Peer IDs are sent as a buffer containing the utf bytes for `/ipns/`
then the bytes that make up the peer id.

Our tests were using a buffer that contained the utf bytes for `/ipns/`
followed by the utf bytes for the base encoded peer id, which is wrong.

I think this only worked previously because the validator passed the
bytes to `PeerId.createFromBytes` which passes them to the `cids` `CID`
class constructor which is a lot more forgiving in terms of input than
the multiformats `CID` class.
@achingbrain achingbrain requested a review from vasco-santos July 11, 2021 18:20
@vasco-santos vasco-santos merged commit d7c8e51 into master Jul 12, 2021
@vasco-santos vasco-santos deleted the fix/parse-peer-id-from-message branch July 12, 2021 07:10
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants